package double_pointer;

public class maxArea2 {
    public int maxArea(int[] height) {
        int left = 0;
        int right = height.length - 1;
        int sum = 0;
        while (left < right) {
            int min = Math.min(height[left], height[right]);
            sum = Math.max(sum, (right - left) * min);
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }

        }
        return sum;
    }
}
